using System.Threading.Tasks;
using Jinjia.Approve.IService.JJFlow;
using Jinjia.Approve.Model.VM.JJFlow;
using Jinjia.Approve.ScheduleJobAPI.Controllers.Base;
using Jinjia.Core.Transaction.Model;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace Jinjia.Approve.ScheduleJobAPI.Controllers
{
    /// <summary>
    /// JJFlow Job Controller
    /// </summary>
    public class JJFlowController : BaseJobController
    {
        private readonly IJJFlowService _jjFlowService;

        public JJFlowController(ILogger<BaseJobController> logger, IJJFlowService jjFlowService) : base(logger)
        {
            _jjFlowService = jjFlowService;
        }

        [NonAction]
        [TransactionCAPSubscribe(typeof(JJFlowOperate))]
        public async Task<IActionResult> JJFlowOperateSubscriber(JJFlowOperate jjFlowOperate)
        {
            await _jjFlowService.SyncFeiShu(jjFlowOperate.InstanceId, jjFlowOperate.TransferEmpId);
            return Success();
        }
    }
}